<!--
 * @Description:
 * @Author: william
 * @Date: 2025-02-17 16:47:40
 * @LastEditors: william
 * @LastEditTime: 2025-05-12 19:13:40
-->
<template>
  <BaseDialog
    v-model="dialogVisible"
    :title="$t('public.detail')"
    width="550px"
    style="width: 550px"
    :before-close="handleClose"
  >
    <el-descriptions
      v-loading="viewLoading"
      :column="1"
      border
      :label-width="140"
    >
      <!-- <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.passId') }}</template>
        {{ formData.id }}
      </el-descriptions-item> -->
      <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.licensePlate') }}</template>
        {{ formData.vehicleEntity?.vehiclePlate || '--' }}
      </el-descriptions-item>
      <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.departure') }}</template>
        <span>{{
          g_utils.getRegionName(formData.startRegionCode) || '--'
        }}</span>
      </el-descriptions-item>
      <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.depDetailAddr') }}</template>
        {{ formData.startAddress }}
      </el-descriptions-item>
      <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.departureTime') }}</template>
        {{ formData.startTime }}
      </el-descriptions-item>
      <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.destination') }}</template>
        <span>{{ g_utils.getRegionName(formData.endRegionCode) || '--' }}</span>
      </el-descriptions-item>
      <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.desDetailAddr') }}</template>
        {{ formData.endAddress }}
      </el-descriptions-item>
      <el-descriptions-item width="300">
        <template #label>{{ $t('public.endTime') }}</template>
        {{ formData.endTime }}
      </el-descriptions-item>
      <!-- <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.passPlace') }}</template>
        {{ formData.regionName }}
      </el-descriptions-item> -->
      <!-- <el-descriptions-item width="300">
        <template #label>{{ $t('public.detailAddress') }}</template>
        {{ formData.startAddress }}
      </el-descriptions-item> -->
      <!-- <el-descriptions-item width="300">
        <template #label>{{ $t('fleet.passTime') }}</template>
        {{ formData.createTime }}
      </el-descriptions-item> -->
      <el-descriptions-item width="300">
        <template #label>{{ $t('public.createTime') }}</template>
        {{ formData.createTime }}
      </el-descriptions-item>
    </el-descriptions>
    <template #footer>
      <div class="detail-dialog-footer">
        <el-button plain @click="handleClose">{{
          $t('public.close')
        }}</el-button>
      </div>
    </template>
  </BaseDialog>
</template>

<script setup>
const props = defineProps({
  id: {
    type: String,
    default: ''
  }
})

const dialogVisible = defineModel({
  type: Boolean,
  default: false
})
const viewLoading = ref(false)
const formData = ref({})

onMounted(() => {
  getFormData()
})

const getFormData = () => {
  viewLoading.value = true
  g_api.fleet
    .apiScheduleDetail({ vehicleScheduleId: props.id })
    .then(({ code, data }) => {
      if (code === '200' && data) {
        formData.value = data
      }
    })
    .finally(_ => {
      viewLoading.value = false
    })
}

const handleClose = () => {
  dialogVisible.value = false
}
</script>

<style scoped lang="scss"></style>
